﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace TowerDefense.model
{
    public class TowerDefenseClass
    {
        public static int ARRAY_SIZE = 101;
        public static int SIZE_PER_TILE = 32; //16 pixels

        public Tile[,] tilesArray = new Tile[ARRAY_SIZE, ARRAY_SIZE];

        public TowerDefenseClass()
        {
            InitializeTiles();
        }

        private void InitializeTiles()
        {
            Unit.WayPoints.Add(new Vector2(0, (float)(Math.Floor(ARRAY_SIZE / 2F))));
            Unit.WayPoints.Add(new Vector2(ARRAY_SIZE, (float)(Math.Floor(ARRAY_SIZE / 2F))));
        }

        public bool AddBuilding(Building building)
        {
            int x = (int)building.Vector.X;
            int y = (int)building.Vector.Y;

            if (tilesArray[x, y].IsUsed)
                return false;

            //Add building stuff
            tilesArray[x, y].IsUsed = true;
            tilesArray[x, y].Building = building;
            building.Tile = tilesArray[x, y];

            return true;
        }
    }
}
